package com.lambda.cloud.config;

import com.lambda.cloud.core.principal.LoginUser;
import com.lambda.security.SimpleLoginUser;
import com.lambda.security.service.UserDetailService;
import lombok.RequiredArgsConstructor;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;

@SuppressWarnings("all")
@Service
@RequiredArgsConstructor
public class UserDetailServiceImpl implements UserDetailService {

    private final PasswordEncoder passwordEncoder;

    @Override
    public LoginUser loginByUsername(String username, String loginType) {
        SimpleLoginUser currentUser = new SimpleLoginUser();
        currentUser.setUsername(username);
        currentUser.setPassword(passwordEncoder.encode("123456"));
        currentUser.setAccountExpired(false);
        currentUser.setAccountLocked(false);
        return currentUser;
    }

    @Override
    public LoginUser loginByMobile(String mobile, String loginType) {
        SimpleLoginUser currentUser = new SimpleLoginUser();
        currentUser.setUsername(mobile);
        currentUser.setPassword(passwordEncoder.encode("123456"));
        currentUser.setAccountExpired(false);
        currentUser.setAccountLocked(false);
        return currentUser;
    }
}
